package com.ruoyi.web.controller.production.blade;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.production.domain.blade.BladePurchaseApply;
import com.ruoyi.production.service.blade.IBladePurchaseApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 刀片购买申请Controller
 *
 * @author ruoyi
 * @date 2021-07-11
 */
@RestController
@RequestMapping("/system/bladeApply")
@Api("刀片购买申请Controller")
public class BladePurchaseApplyController extends BaseController
{
    @Autowired
    private IBladePurchaseApplyService bladePurchaseApplyService;

    /**
     * 查询刀片购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:bladeApply:list')")
    @GetMapping("/list")
    @ApiOperation("查询刀片购买申请列表")
    public TableDataInfo list(BladePurchaseApply bladePurchaseApply)
    {
        startPage();
        List<BladePurchaseApply> list = bladePurchaseApplyService.selectBladePurchaseApplyList(bladePurchaseApply);
        return getDataTable(list);
    }

    /**
     * 导出刀片购买申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:bladeApply:export')")
    @Log(title = "刀片购买申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BladePurchaseApply bladePurchaseApply)
    {
        List<BladePurchaseApply> list = bladePurchaseApplyService.selectBladePurchaseApplyList(bladePurchaseApply);
        ExcelUtil<BladePurchaseApply> util = new ExcelUtil<BladePurchaseApply>(BladePurchaseApply.class);
        return util.exportExcel(list, "刀片购买申请数据");
    }

    /**
     * 获取刀片购买申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:bladeApply:query')")
    @GetMapping(value = "/{bladePurchaseApplyId}")
    public AjaxResult getInfo(@PathVariable("bladePurchaseApplyId") Long bladePurchaseApplyId)
    {
        return AjaxResult.success(bladePurchaseApplyService.selectBladePurchaseApplyById(bladePurchaseApplyId));
    }

    /**
     * 新增刀片购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:bladeApply:add')")
    @Log(title = "刀片购买申请", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增刀片购买申请")
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody BladePurchaseApply bladePurchaseApply)
    {
        return toAjax(bladePurchaseApplyService.insertBladePurchaseApply(bladePurchaseApply));
    }

    /**
     * 修改刀片购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:bladeApply:edit')")
    @Log(title = "刀片购买申请", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改刀片申请")
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody BladePurchaseApply bladePurchaseApply)
    {
        return toAjax(bladePurchaseApplyService.updateBladePurchaseApply(bladePurchaseApply));
    }

    /**
     * 删除刀片购买申请
     */
    @PreAuthorize("@ss.hasPermi('system:bladeApply:remove')")
    @Log(title = "刀片购买申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bladePurchaseApplyIds}")
    @ApiOperation("删除刀片购买申请")
    public AjaxResult remove(@PathVariable Long[] bladePurchaseApplyIds)
    {
        return toAjax(bladePurchaseApplyService.deleteBladePurchaseApplyByIds(bladePurchaseApplyIds));
    }
}
